package cn.cmkj.auction.data.http;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by cunguoyao on 2017/12/22.
 */

public class MainNotice implements Serializable {

    public long notice_id;
    public String notice_describe;
    public String notice_content;
    public String notice_type;
    public int is_used;
    public long start_time;
    public long end_time;
    public long add_time;

    public static List<MainNotice> parseJsonArray(JSONArray jsonArray) {
        List<MainNotice> list = new ArrayList<>();
        if(jsonArray != null && jsonArray.length() > 0){
            for(int i=0;i<jsonArray.length();i++){
                list.add(parseFromJson(jsonArray.optJSONObject(i)));
            }
        }
        return list;
    }

    public static MainNotice parseFromJson(JSONObject json) {
        if (json == null) return null;
        MainNotice bean = new MainNotice();
        bean.notice_id = json.optLong("notice_id", 0);
        bean.notice_describe = json.optString("notice_describe", "");
        bean.notice_content = json.optString("notice_content", "");
        bean.notice_type = json.optString("notice_type", "");
        bean.is_used = json.optInt("is_used", 0);
        bean.start_time = json.optLong("start_time", 0);
        bean.end_time = json.optLong("end_time", 0);
        bean.add_time = json.optLong("add_time", 0);
        return bean;
    }
}
